﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.IO;
using System.ServiceProcess;
using System.ServiceProcess.Design;
namespace SES_Server
{
    public class IIS_SES_Relay_Server : ServiceBase
    {
        Thread runningThread;
        public IIS_SES_Relay_Server()
        {
            InitializeComponent();
        }
        protected override void OnStart(string[] args)
        {
            runningThread = new Thread(new ThreadStart(Start));
            runningThread.Start();

        }
        protected override void OnStop()
        {
            runningThread.Abort();
            this.EventLog.WriteEntry("Amazon SES SMTP Server Has Stopped");
        }
        private void InitializeComponent()
        {
            this.ServiceName = "Amazon SES SMTP Server";

            this.CanStop = true;

            this.AutoLog = false;

            this.EventLog.Log = "Application";

            this.EventLog.Source = "Amazon SES SMTP Server";
        }
        public void Start()
        {
            SMTPProcessor processor = new SMTPProcessor();
            processor.Start();
        }

        
    }
}
